package com.qfmy.web.app.controller.listenBook;

import com.qfmy.common.result.Result;
import com.qfmy.model.entity.listenBook.AudioComment;
import com.qfmy.model.vo.listenBook.AudioCommentVo;
import com.qfmy.web.app.service.listenBook.AudioCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.qfmy.web.app.controller.listenBook
 * @date 2025/11/01
 * @description 评论表
 */
@RestController
@RequestMapping("/app/audioComment")
public class AudioCommentController {

    /**
     * 注入评论服务
     */
    @Autowired
    private AudioCommentService audioCommentService;

    /**
     * 添加评论
     */
    @RequestMapping("/addAudioComment")
    public Result addAudioComment(@RequestBody  AudioComment audioComment) {
        audioCommentService.addComment(audioComment);
        return Result.ok();
    }

    /**
     * 判断用户是否以及评论
     */
    @RequestMapping("/isUserComment")
    public Result isUserComment(@RequestParam Integer audioId) {
        boolean result = audioCommentService.isUserComment(audioId);
        return Result.ok(result);
    }

    /**
     * 获取所有的评论
     */
    @RequestMapping("/getAllAudioComment")
    public Result<List<AudioCommentVo>> getAllAudioComment(@RequestParam Integer audioId) {
        List<AudioCommentVo> list = audioCommentService.getAllAudioComment(audioId);
        return Result.ok(list);
    }

}
